package com.shao.onlinepdf.dto;

/**
 * 结果类
 * @author shaohuailin
 * @date 2021/11/19
 */
public class Result {
    /** 成功状态标识 */
    private static final int CODE_SUCCESS = 0;
    /** 失败状态标识 */
    private static final int CODE_FAIL = 1;

    /** 状态标识 */
    private Integer code;
    /** 数据 */
    private Object data;

    public Result(Integer code, Object data) {
        this.code = code;
        this.data = data;
    }

    public static Result success(Object data) {
        return new Result(CODE_SUCCESS, data);
    }
    public static Result fail(Object data) {
        return new Result(CODE_FAIL, data);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", data=" + data +
                '}';
    }
}
